package
{
	import flash.display.Stage;
	import flash.events.KeyboardEvent;

	public class csKeyMap
	{
		private var _keyStatusMap:Object = new Object();
		
		public function csKeyMap()
		{
		}

		public function init(stage:Stage):void
		{
			trace("csKeyMap.init, stage = " + stage);
			
			stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
			stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
			
			function onKeyDown(e:KeyboardEvent):void
			{
//				trace("key down, code = " + e.keyCode);
				_keyStatusMap[e.keyCode] = 1;
			}
			
			function onKeyUp(e:KeyboardEvent):void
			{
//				trace("key up, code = " + e.keyCode);
				_keyStatusMap[e.keyCode] = 0;
			}
			
		}
		
		public function isDown(keyCode:int):Boolean
		{
			return _keyStatusMap[keyCode] == 1;
		}
		
		public function setStatus(keyCode:int, status:int):void
		{
			_keyStatusMap[keyCode] = status;
		}
		
	}
}